package com.infovane.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.infovane.dao.AdminDao;

public class AdminDaoImpl extends HibernateDaoSupport implements AdminDao{
	
	
	/**
	 *根据用户名和密码检索用户
	 *@param username ,password
	 *@return List
	 * */
	public List load(final String hql,final String username,final String password) {
		List list=this.getHibernateTemplate().executeFind(new HibernateCallback(){

			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				Query query = session.createQuery(hql);
				query.setParameter("userName", username);
				query.setParameter("userPass", password);
				List list = query.list();
				logger.info("load successful!");
				return list;
			}
			
		});
		return list;
	}

}
